package com.correction.classes;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.correction.classes.Utilisateur.Niveau;

@Entity
@Table(name = "examen")
public class Examen {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "idExamen")
	private int idExamen;
	@Column(name = "titre")
	private String titre;

	@Column(name = "niveau")
	@Enumerated(EnumType.STRING)
	private Niveau niveau;
	@Column(name = "dateActivation")
	private Date dateActivation;
	@Column(name = "dateDesactivation")
	private Date dateDesactivation;

	@OneToMany(cascade = CascadeType.ALL)
	@LazyCollection(LazyCollectionOption.FALSE)
	@JoinColumn(name = "idExamen", nullable = true)
	@ForeignKey(name = "FK_ExerciceId")
	private List<Exercice> exercices = new ArrayList<Exercice>();

	public String getTitre() {
		return titre;
	}

	public void setTitre(String titre) {
		this.titre = titre;
	}

	public int getIdExamen() {
		return idExamen;
	}

	public void setIdExamen(int idExamen) {
		this.idExamen = idExamen;
	}

	public Niveau getNiveau() {
		return niveau;
	}

	public void setNiveau(Niveau niveau) {
		this.niveau = niveau;
	}

	public Date getDateActivation() {
		return dateActivation;
	}

	public void setDateActivation(Date dateActivation) {
		this.dateActivation = dateActivation;
	}

	public Date getDateDesactivation() {
		return dateDesactivation;
	}

	public void setDateDesactivation(Date dateDesactivation) {
		this.dateDesactivation = dateDesactivation;
	}

	public List<Exercice> getExercices() {
		return exercices;
	}

	public void setExercices(List<Exercice> exercices) {
		this.exercices = exercices;
	}

	@Override
	public String toString() {
		return "Examen [idExamen=" + idExamen + ", titre=" + titre
				+ ", niveau=" + niveau + ", dateActivation=" + dateActivation
				+ ", dateDesactivation=" + dateDesactivation + ", exercices="
				+ exercices + "]";
	}


}
